package com.xcc.annotation.ioc.config;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * 后置处理器：初始化前后进行处理工作
 *  @Component 将后置处理器加入到容器中
 */
@Component
public class Demo04_BeanPostProccessor implements BeanPostProcessor {

    /**
     * 初始化前进行的工作
     */
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("postProcessBeforeInitialization....."+beanName+" ==> "+bean);
        return bean;
    }

    /**
     * 初始化后进行的工作
     */
    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("postProcessAfterInitialization....."+beanName+" ==> "+bean);
        return bean;
    }
}
